package spring.framework.beans;

import cn.hutool.core.util.StrUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fun.pengzh
 * @class spring.framework.beans.factory.PropertyValues
 * @desc
 * @since 2021-10-07
 */
public class PropertyValues {

    private List<PropertyValue> propertyValues = new ArrayList<>();

    public void addPropertyValue(PropertyValue propertyValue) {
        this.propertyValues.add(propertyValue);
    }

    public PropertyValue[] getPropertyValues() {
        return propertyValues.toArray(new PropertyValue[0]);
    }

    public PropertyValue getPropertyValue(String propertyName) {
        for (PropertyValue propertyValue : propertyValues) {
            if (StrUtil.equals(propertyName, propertyValue.getName())) {
                return propertyValue;
            }
        }
        return null;
    }

}
